using System;
using System.Collections.Generic;
using System.Text;

namespace TKCCLD
{
    public class Repository : IRepository
    {
        public void EndEdit(System.Windows.Forms.BindingSource source)
        {
            source.EndEdit();
        }

        public void CancelEdit(System.Windows.Forms.BindingSource source)
        {
            source.CancelEdit();
        }

        public void CloseEditor(DevExpress.XtraGrid.Views.Grid.GridView gridView)
        {
            gridView.CloseEditor();
        }
        
        public void FetchField(SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2 currentEntity, SD.LLBLGen.Pro.ORMSupportClasses.EntityBase2 storageEntity)
        {
            currentEntity.Fields = storageEntity.Fields;
        }

        public void FetchState(String state, DevExpress.XtraBars.BarManager barManager)
        {
            switch (state)
            {
                case "IsFetch":
                    barManager.Items[0].Enabled = true;
                    barManager.Items[1].Enabled = false;
                    barManager.Items[2].Enabled = false;
                    barManager.Items[3].Enabled = false;
                    barManager.Items[4].Enabled = true;
                    barManager.Items[5].Enabled = true;
                    barManager.Items[6].Enabled = true;
                    break;
                case "IsNew":
                    barManager.Items[0].Enabled = false;
                    barManager.Items[1].Enabled = true;
                    barManager.Items[2].Enabled = true;
                    barManager.Items[3].Enabled = false;
                    barManager.Items[4].Enabled = false;
                    barManager.Items[5].Enabled = false;
                    barManager.Items[6].Enabled = false;
                    break;
                case "IsDirty":
                    barManager.Items[0].Enabled = false;
                    barManager.Items[1].Enabled = false;
                    barManager.Items[2].Enabled = true;
                    barManager.Items[3].Enabled = true;
                    barManager.Items[4].Enabled = false;
                    barManager.Items[5].Enabled = false;
                    barManager.Items[6].Enabled = false;
                    break;
            }
        }

        public void FetchRight(DevExpress.XtraBars.BarManager barManager)
        {
            barManager.Items[0].Enabled = false;
            barManager.Items[1].Enabled = false;
            barManager.Items[2].Enabled = false;
            barManager.Items[3].Enabled = false;
            barManager.Items[4].Enabled = false;
            barManager.Items[5].Enabled = true;
            barManager.Items[6].Enabled = true;
        }
    }
}
